var commentpid ;
 	$(document).ready(function(){   
 　 		 
 		var topicid = {topicid:"${topicid}"}
  		$.ajax({ 
			url: "../../topicclick.do" ,
			type:'post', //数据发送方式 
			dataType:'json', //接受数据格式 
			data: topicid ,  
			success:update_page2 //回传函数(这里是函数名)   error转向错误页面
            }); 
            
            
             $("#shoucang").bind("click", function(){
             var topicid = {topicid:"${topicid}"}
            $.ajax({
            type:"POST",
            url: "../../shoucang.do", 
            dataType:'html', //接受数据格式
            async: false,
            data: topicid,

            success: function(data){ 
           
                    alert("收藏成功！");
                 
                },
           error:function(data){
             alert(data);
           }
            }) 
          }) 
            
　　　});   
 	
   function changepin(aobj){
    commentpid = aobj;
    var str = $('#'+aobj).text(); 
     if(str.length == 0){ 
       var str2 = aobj.substring(2);
       var sendData="pid="+str2;
       $.ajax({ 
			url: "../../loadcomments.do" ,
			type:'post', //数据发送方式 
			dataType:'json', //接受数据格式 
			data: sendData , 
			// beforeSend: function() {$("<img src='../images/wait18.gif' />").appendTo("#DivTblContact")},  
			success:update_page //回传函数(这里是函数名)   error转向错误页面
            });   
       $('#'+aobj).hide();
     }  
      $('#'+aobj).toggle();  
   }
   
    function update_page(obj) { //ajax保存成功后,触发 id为rain 的onclick事件
    	var tablestr = "<table>"; 
    	if(obj.comments.length != 0){
        for(data in obj.comments){
           	  var bean = obj.comments[data];
           	  tablestr += "<tr><td>"+bean.lou+"</td><td><img src='../../pages/topics/usermanager/userphoto/"+bean.comment[2]+"' width='50' height='50' />"
           	               +"<br/>"+bean.comment[1]+"</td><td>"+bean.comment[3]+"<br/><span>"+bean.comment[0]+"</span></td></tr>";    	    
    	    
    	  }
    	   tablestr +="</table>";
    	  }else {
    	 　 alert("此图片暂无评论");
    	   tablestr = "";
    	  }
    	 
    	 $(tablestr).appendTo($('#'+commentpid)); 
     } 		
       
       function publiscomment_f(obj){
       		document.getElementById('pictureid').value=obj;
       		$('#username').focus(); 
       }
       function sendSubmit(){
         var picturid = $('#pictureid').val();
         var username = $('#username').val();
         var commenttext = $('#commenttext').val();
         if(commenttext.length == 0){
          alert("评论内容不能为空");
          $('#commenttext').focus();
          return;
         }
         if(picturid.length == 0){
          alert("你如果想对哪个图片，请点击对应图片下面的'发表评论'！");　
          return;
         }
         var commentData = "picturid="+picturid+"&username="+username+"&commenttext="+commenttext;
         $.ajax({ 
			url: "../../publiscomments.do" ,
			type:'post', //数据发送方式 
			dataType:'json', //接受数据格式 
			data: commentData , 
			// beforeSend: function() {$("<img src='../images/wait18.gif' />").appendTo("#DivTblContact")},  
			success:publish_page //回传函数(这里是函数名)   error转向错误页面
         　});
         
       }
       function publish_page(obj){
        if(obj == 1){
          alert("发表成功！");
         　  window.location.reload();
        }else{
          $('#loginorregister').trigger('click');
        }
       }
       
       function update_page2(data){ 
           if(data.username == null){
        	  var nologinstr =  "<a href='../../index.html'>首页</a>&nbsp;|&nbsp;<a href='../../pages/topics/usermanager/register.jsp'>快速注册</a>&nbsp;|&nbsp;<a href='../../pages/topics/usermanager/userlogin.jsp'>登录</a>&nbsp;|&nbsp;<a href='#' onClick ='javascript:window.external.AddFavorite(document.URL,document.title);return false'>收藏</a>";
         	  $('#info').html("");
          　	  $(nologinstr).appendTo($('#info')); 
           }else{
                var str = "<a href='../../index.html'>首页</a>&nbsp;|&nbsp;<a href='../../userblog.do?userid="+data.userid+"'>"+data.username+"</a>&nbsp;|&nbsp; <a href='../../userinfoset.do'>管理中心</a> &nbsp;|&nbsp; <a href='../../userexit.do' >退出</a>&nbsp;|&nbsp;<a href='#' onClick ='javascript:window.external.AddFavorite(document.URL,document.title);return false'>收藏</a>";
               $('#info').html("");
               $(str).appendTo($('#info')); 
           }  
       }
       
       function loginout(){
       $.ajax({
            type:"POST",
            url: "../../userlogin.do?action=loginout", 
            dataType:'html', //接受数据格式 
            success: function(data){ 
             	 window.location="../../index.html";
                } 
			 
	    })
       }
       function clickbiaoqing(obj){  
         if(obj == 1){
          insertText(":daxiao:");
         }else if(obj == 2){
          insertText(":jingya:");
         }else if(obj == 3){
           insertText(":sharen:");
         }else if(obj == 4){
           insertText(":henku:");
         }else if(obj == 5){
           insertText(":kule:");
         }else if(obj == 6){
          insertText(":wuli:");
         }else{
          insertText(":yawen:");
         } 
       }
       function insertText(str){ 
          var att =  document.getElementById('commenttext').innerText; 
          document.getElementById('commenttext').innerText = att+str;
         
       }
      